﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MvcEngine.Core.Helpers
{
    /// <summary>
    /// This is used as an abstraction for session variables. The intention is to make using session variable names
    /// a bit safer, by adding a 'scope' name. The scope can be a component name, a class name or any other name that can define
    /// a scope. The session variable will then only be known inside that scope and will therefore not conflict with any
    /// other session variables elsewhere in the application that happen to have the same name.
    /// </summary>
    public interface IHttpSessionHelper
    {
        /// <summary>
        /// Remove the key from session.
        /// </summary>
        /// <param name="scope">The scope.</param>
        /// <param name="key">The key.</param>
        void ClearSessionValue(string scope, string key);

        void ClearSessionValue(string key);

        /// <summary>
        /// Gets the session value.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="scope">The scope.</param>
        /// <param name="key">The key.</param>
        /// <returns>Value. If key does not exists, <see langword="null"/> will be returned.</returns>
        T GetSessionValue<T>(string scope, string key);

        T GetSessionValue<T>(string key);

        /// <summary>
        /// Determines whether the specified key in the scope is empty.
        /// </summary>
        /// <param name="scope">The scope.</param>
        /// <param name="key">The key.</param>
        /// <returns>
        ///<c>false</c> if the specified key in scope does not exists or <see langword="null"/> ; otherwise, <c>true</c>.
        /// </returns>
        bool IsSessionValueEmpty(string scope, string key);

        bool IsSessionValueEmpty(string key);

        /// <summary>
        /// Sets the session value. If key does not exists it will be created, otherwise existing key will be overwritten.
        /// The session should be initialized.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="scope">The scope.</param>
        /// <param name="key">The key.</param>
        /// <param name="value">The value.</param>
        void SetSessionValue<T>(string scope, string key, T value);

        void SetSessionValue<T>(string key, T value);
    }
}
